<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>value_from</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.JSON">
<link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
<link rel="prev" href="boost__json__value_to.html" title="value_to">
<link rel="next" href="boost__json__get.html" title="get">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__value_to.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__get.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="json.ref.boost__json__value_from"></a><a class="link" href="boost__json__value_from.html" title="value_from">value_from</a>
</h4></div></div></div>
<p>
        <a class="indexterm" name="idm45725618576704"></a>
      </p>
<p>
        Convert an object of type <code class="computeroutput"><span class="identifier">T</span></code>
        to <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>.
      </p>
<h5>
<a name="json.ref.boost__json__value_from.h0"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_from.synopsis"></a></span><a class="link" href="boost__json__value_from.html#json.ref.boost__json__value_from.synopsis">Synopsis</a>
      </h5>
<p>
        Defined in header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json/value_from.hpp" target="_top">boost/json/value_from.hpp</a>&gt;</code>
      </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="identifier">value</span>
<span class="identifier">value_from</span><span class="special">(</span>
    <span class="identifier">T</span><span class="special">&amp;&amp;</span> <span class="identifier">t</span><span class="special">,</span>
    <span class="identifier">storage_ptr</span> <span class="identifier">sp</span> <span class="special">=</span> <span class="special">{});</span>
</pre>
<h5>
<a name="json.ref.boost__json__value_from.h1"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_from.description"></a></span><a class="link" href="boost__json__value_from.html#json.ref.boost__json__value_from.description">Description</a>
      </h5>
<p>
        This function attempts to convert an object of type <code class="computeroutput"><span class="identifier">T</span></code>
        to <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>
        using
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            one of <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>'s
            constructors,
          </li>
<li class="listitem">
            a library-provided generic conversion, or
          </li>
<li class="listitem">
            a user-provided overload of <code class="computeroutput"><span class="identifier">tag_invoke</span></code>.
          </li>
</ul></div>
<p>
        In all cases, the conversion is done by calling an overload of <code class="computeroutput"><span class="identifier">tag_invoke</span></code> found by argument-dependent
        lookup. Its signature should be similar to:
      </p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">tag_invoke</span><span class="special">(</span> <span class="identifier">value_from_tag</span><span class="special">,</span> <span class="identifier">value</span><span class="special">&amp;,</span> <span class="identifier">T</span> <span class="special">);</span>
</pre>
<p>
        A <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>
        constructed with the <a class="link" href="boost__json__storage_ptr.html" title="storage_ptr"><code class="computeroutput"><span class="identifier">storage_ptr</span></code></a> passed to <a class="link" href="boost__json__value_from.html" title="value_from"><code class="computeroutput"><span class="identifier">value_from</span></code></a> is passed as the second
        argument to ensure that the memory resource is correctly propagated.
      </p>
<h5>
<a name="json.ref.boost__json__value_from.h2"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_from.exception_safety"></a></span><a class="link" href="boost__json__value_from.html#json.ref.boost__json__value_from.exception_safety">Exception
        Safety</a>
      </h5>
<p>
        Strong guarantee.
      </p>
<h5>
<a name="json.ref.boost__json__value_from.h3"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_from.template_parameters"></a></span><a class="link" href="boost__json__value_from.html#json.ref.boost__json__value_from.template_parameters">Template Parameters</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Type
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody><tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">T</span></code>
                </p>
              </td>
<td>
                <p>
                  The type of the object to convert.
                </p>
              </td>
</tr></tbody>
</table></div>
<h5>
<a name="json.ref.boost__json__value_from.h4"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_from.return_value"></a></span><a class="link" href="boost__json__value_from.html#json.ref.boost__json__value_from.return_value">Return
        Value</a>
      </h5>
<p>
        <code class="computeroutput"><span class="identifier">t</span></code> converted to <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>.
      </p>
<h5>
<a name="json.ref.boost__json__value_from.h5"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_from.parameters"></a></span><a class="link" href="boost__json__value_from.html#json.ref.boost__json__value_from.parameters">Parameters</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Name
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">t</span></code>
                </p>
              </td>
<td>
                <p>
                  The object to convert.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">sp</span></code>
                </p>
              </td>
<td>
                <p>
                  A storage pointer referring to the memory resource to use for the
                  returned <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>. The default argument
                  for this parameter is <code class="computeroutput"><span class="special">{}</span></code>.
                </p>
              </td>
</tr>
</tbody>
</table></div>
<h5>
<a name="json.ref.boost__json__value_from.h6"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_from.see_also"></a></span><a class="link" href="boost__json__value_from.html#json.ref.boost__json__value_from.see_also">See
        Also</a>
      </h5>
<p>
        <a class="link" href="boost__json__value_from_tag.html" title="value_from_tag"><code class="computeroutput"><span class="identifier">value_from_tag</span></code></a>,
        <a class="link" href="boost__json__value_to.html" title="value_to"><code class="computeroutput"><span class="identifier">value_to</span></code></a>,
        <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf" target="_top">tag_invoke:
        A general pattern for supporting customisable functions</a>
      </p>
<p>
        Convenience header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json.hpp" target="_top">boost/json.hpp</a>&gt;</code>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Vinnie Falco<br>Copyright © 2020 Krystian Stasiowski<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__value_to.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__get.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
